package com.sl.au.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.xml.crypto.Data;

import com.sl.au.entity.User;

/**
 * @author Neil
 *通过EM来操作数据
 */
public interface QueryService extends BaseService {
	/**生成日期属性查询hql
	 * @param hsql
	 * @param paramsMap
	 * @param propertyName
	 * @param startDate
	 * @param endDate
	 */
	public void buildDateCriterionHql(StringBuilder hql, 
			Map<String,Object> paramsMap, 
            String propertyName, 
            Date startDate, 
            Date endDate);
	/**生成String类型属性查询hql
	 * @param hql
	 * @param paramsMap
	 * @param propertyName
	 * @param value
	 */
	public void buildStringCriterionHql(StringBuilder hql, 
			Map<String,Object> paramsMap, 
	        String propertyName, 
	        String value) ;
	/**通过实体动态组合查询
	 * @param entityName
	 * @param qMap查询属性名称及值
	 * @return
	 */
	public <T> List<T> combinedQueryHql(String entityName,String selectedProperty,Map<String,Object>  qMap,int start,int length,User user,String orderName,String dir);
	 public long combinedQueryCountHql(String entityName,Map<String,Object>  qMap);
	 
	 /**返回单个实体查询HQL
	 * @param entityName
	 * @param map
	 * @return
	 */
	public StringBuilder buildCombinedQueryHql(String entityName,String selectedProperty, Map<String, Object> map,Map<String,Object> namedParamsMap,Map<String,Object> numMap,User user);
	 
	
	/**执行查询HQL，返回实体列表
	/**
	 * @param hql
	 * @param namedParamsMap
	 * @return
	 */
	public <T> List<T> executeHql(Query query,Map<String,Object> namedParamsMap);
	/**生成一个查询对象
	 * @param hql
	 * @return
	 */
	public Query createQueryHql(String hql);
	/**返回实体管理对象
	 * @return
	 */
	public EntityManager getEM();
	 /**返回单个实体查询HQL
	 * @param entityName
	 * @param map
	 * @return
	 */
	void buildFloatCriterionHql(StringBuilder hql, Map<String, Object> paramsMap, String propertyName, float startNum, float endNum);
	
	/**
	 * 返回单个实体查询HQL
	 * @param hql
	 * @param paramsMap
	 * @param propertyName
	 * @param startNum
	 * @param endNum
	 */
	void buildIntCriterionHql(StringBuilder hql, Map<String, Object> paramsMap, String propertyName, int startNum, int endNum);
	/**
	 * 返回单个实体查询HQL
	 * @param hql
	 * @param paramsMap
	 * @param propertyName
	 * @param startNum
	 * @param endNum
	 */
	void buildDoubleCriterionHql(StringBuilder hql, Map<String, Object> paramsMap, String propertyName, double startNum, double endNum);

	void setNamedParams(Query query, Map<String, Object> namedParamsMap);
}




